﻿<Captcha ImagesPath="@ImagesPath" @ref="Captcha" OnValidAsync="@OnValidAsync" Max="9" />
<ConsoleLogger @ref="Logger" class="mt-3" />

@code {
    /// <summary>
    /// 获得/设置 图床路径 默认值为 images
    /// </summary>
    public string ImagesPath { get; set; } = "_content/BootstrapBlazor.Shared/images";

    [NotNull]
    private Captcha? Captcha { get; set; }

    [NotNull]
    private ConsoleLogger? Logger { get; set; }

    private async Task OnValidAsync(bool ret)
    {
        var result = ret ? "成功" : "失败";
        Logger.Log($"验证码结果 -> {result}");
        if (ret)
        {
            await Task.Delay(1000);
            await Captcha.Reset();
        }
    }
}
